// eslint-disable-next-line
import axios from "axios";

// eslint-disable-next-line import/no-anonymous-default-export
export default {
    // 获取全部数据
    get: ({ curPage, eachPage }) =>
        axios.get('/api/address', {
            params: { curPage, eachPage }
        }).then(({ data }) => data),
    // 新增数据
    add: ({ name, address, phone, Open_hours, longitude, latitude, imgs }) =>
        axios.post('/api/address/add', {
            name, address, phone, Open_hours, longitude, latitude, imgs
        }).then(({ data }) =>
            data
        ),
    // 删除数据
    remove: ({ _id }) => axios.delete(`/api/address/${_id}`).then(({ data }) => data),

    // 修改数据
    amend: ({ name, address, phone, Open_hours, longitude, latitude, _id }) => axios.patch(`/api/address/amend`, {
        name, address, phone, Open_hours, longitude, latitude, _id
    }).then(({ data }) => data),

    // 查找一条数据
    getOne: ({ _id }) => axios.get(`/api/address/getone`, {
        params: { _id }
    }).then(({ data }) => data),

    // 查询数据
    getsearch: ({ name }) => axios.get(`/api/address/getsearch`, {
        params: { name }
    }).then(({ data }) => data),

    //删除图片
    removeImg: ({ _id, url }) => axios.delete(`/resource/address/${_id}/address/${encodeURIComponent(url)} `,).then(({ data }) => data),
}
